//jQuery time
var current_fs, next_fs, previous_fs; //fieldsets
var left, opacity, scale; //fieldset properties which we will animate
var animating; //flag to prevent quick multi-click glitches
 $('#msform').bootstrapValidator({
        message: '这个值没有被验证',
        feedbackIcons: {
            valid: 'glyphicon glyphicon-ok',
            invalid: 'glyphicon glyphicon-remove',
            validating: 'glyphicon glyphicon-refresh'
        },
        fields: {
            email: {
                validators: {
                    notEmpty: {
                        message: '邮箱是必填项'
                    },
                    emailAddress: {
                        message: '邮箱格式不正确'
                    }
                }
            },
            Username: {
                message: '用户名还没有验证',
                validators: {
                    notEmpty: {
                        message: '用户名不能为空'
                    }
                }
            },
            gender: {
                message: '性别还没有验证',
                validators: {
                    notEmpty: {
                        message: '性别不能为空'
                    }
                }
            },
            birthday: {
                message: '出生日期还没有验证',
                validators: {
                    notEmpty: {
                        message: '出生日期不能为空'
                    }
                }
            },
            age: {
                message: '年龄还没有验证',
                validators: {
                    notEmpty: {
                        message: '年龄不能为空'
                    }
                }
            },
            nation: {
                message: '民族还没有验证',
                validators: {
                    notEmpty: {
                        message: '民族不能为空'
                    }
                }
            },
            stature: {
                message: '身高还没有验证',
                validators: {
                    notEmpty: {
                        message: '身高不能为空'
                    }
                }
            },
            weight: {
                message: '体重还没有验证',
                validators: {
                    notEmpty: {
                        message: '体重不能为空'
                    }
                }
            },
            condition: {
                message: '健康状况还没有验证',
                validators: {
                    notEmpty: {
                        message: '健康状况不能为空'
                    }
                }
            },
            jsposition: {
                message: '职位没有验证',
                validators: {
                    notEmpty: {
                        message: '职位不能为空'
                    }
                }
            },
            salary: {
                message: '期望待遇还没有验证',
                validators: {
                    notEmpty: {
                        message: '期望待遇不能为空'
                    }
                }
            },
            peoplenum1: {
                message: '期望待遇还没有验证'
            },
            peoplenum2: {
                message: '期望待遇还没有验证'
            },
            peoplenum3: {
                message: '期望待遇还没有验证'
            },
            category: {
                message: '职系类别还没有验证',
                validators: {
                    notEmpty: {
                        message: '职系类别不能为空'
                    }
                }
            },
            channel: {
                message: '渠道还没有验证',
                validators: {
                    notEmpty: {
                        message: '渠道不能为空'
                    }
                }
            },
            telephone: {
                message: '联系电话还没有验证',
                validators: {
                    notEmpty: {
                        message: '联系电话不能为空'
                    }
                }
            },
            marriage: {
                message: '婚姻状况还没有验证',
                validators: {
                    notEmpty: {
                        message: '婚姻状况不能为空'
                    }
                }
            },
            children: {
                message: '子女状况还没有验证',
                validators: {
                    notEmpty: {
                        message: '子女状况不能为空'
                    }
                }
            },
            idnumber: {
                message: '身份证号还没有验证',
                validators: {
                    notEmpty: {
                        message: '身份证号不能为空'
                    }
                }
            },
            register: {
                message: '户籍地址还没有验证',
                validators: {
                    notEmpty: {
                        message: '户籍地址不能为空'
                    }
                }
            },
            address: {
                message: '现住址还没有验证',
                validators: {
                    notEmpty: {
                        message: '现住址不能为空'
                    }
                }
            },
            
            
//          Password: {
//              message: '密码还没有验证',
//              validators: {
//                  notEmpty: {
//                      message: '密码不能为空'
//                  },
//                  stringLength: {
//                      min: 6,
//                      max: 16,
//                      message: '密码长度在6到16之间'
//                  },
//                  different: {
//                      field: 'Username',
//                      message: '密码不能和用户名相同'
//                  }
//              }
//          },
//          Confirm: {
//              message: '密码重复还没有验证',
//              validators: {
//                  notEmpty: {
//                      message: '密码重复不能为空'
//                  },
//                  stringLength: {
//                      min: 6,
//                      max: 16,
//                      message: '密码长度在6到16之间'
//                  },
//                  identical: {
//                      field: 'Password',
//                      message: '两次密码不同请重新输入'
//                  }
//              }
//          }
        }
    })
$(".next").click(function(){
	 var bootstrapValidator = $("#msform").data('bootstrapValidator');
        //手动触发验证
        bootstrapValidator.validate();
        if(bootstrapValidator.isValid()){
           if(animating) return false;
	animating = true;
	
	current_fs = $(this).parent();
	next_fs = $(this).parent().next();
	
	//activate next step on progressbar using the index of next_fs
	$("#progressbar li").eq($("fieldset").index(next_fs)).addClass("active");
	
	//show the next fieldset
	next_fs.show(); 
	//hide the current fieldset with style
	current_fs.animate({opacity: 0}, {
		step: function(now, mx) {
			//as the opacity of current_fs reduces to 0 - stored in "now"
			//1. scale current_fs down to 80%
			scale = 1 - (1 - now) * 0.2;
			//2. bring next_fs from the right(50%)
			left = (now * 50)+"%";
			//3. increase opacity of next_fs to 1 as it moves in
			opacity = 1 - now;
			current_fs.css({'transform': 'scale('+scale+')'});
			next_fs.css({'left': left, 'opacity': opacity});
		}, 
		duration: 800, 
		complete: function(){
			current_fs.hide();
			animating = false;
		}, 
		//this comes from the custom easing plugin
		easing: 'easeInOutBack'
	}); 
        }else{
        	alert("未按要求填写")
        }
});

$(".previous").click(function(){
	if(animating) return false;
	animating = true;
	
	current_fs = $(this).parent();
	previous_fs = $(this).parent().prev();
	
	//de-activate current step on progressbar
	$("#progressbar li").eq($("fieldset").index(current_fs)).removeClass("active");
	
	//show the previous fieldset
	previous_fs.show(); 
	//hide the current fieldset with style
	current_fs.animate({opacity: 0}, {
		step: function(now, mx) {
			//as the opacity of current_fs reduces to 0 - stored in "now"
			//1. scale previous_fs from 80% to 100%
			scale = 0.8 + (1 - now) * 0.2;
			//2. take current_fs to the right(50%) - from 0%
			left = ((1-now) * 50)+"%";
			//3. increase opacity of previous_fs to 1 as it moves in
			opacity = 1 - now;
			current_fs.css({'left': left});
			previous_fs.css({'transform': 'scale('+scale+')', 'opacity': opacity});
		}, 
		duration: 800, 
		complete: function(){
			current_fs.hide();
			animating = false;
		}, 
		//this comes from the custom easing plugin
		easing: 'easeInOutBack'
	});
});

$(".submit").click(function(){
	return false;
})